<template>
  <Framework>
    <template #title>
      学生个性化画像分析系统
    </template>
    <div class="page-layout">
      <!-- 左侧列布局 -->
      <div class="left-column">
        <!-- 顶部面板布局 -->
        <div class="top-panel">
          <div class="left-panel">
            <div class="content">
              <div class="search">
                <slot name="select"></slot>
              </div>
              <div class="panel-content panel">
                <div class="switch-btn prev" @click="switchStudent('prev')"></div>
                <div class="switch-btn next" @click="switchStudent('next')"></div>
                <h5 class="tech-title ">学生详情</h5>
                <div class="detail-content">
                  <div class="panel-content-top">
                    <div class="top-left">
                      <slot name="top-left"></slot>
                    </div>
                    <div class="top-right">
                      <div class="right-top">
                        <slot name="right-top"></slot>
                      </div>
                      <div class="class-name">
                        <slot name="class-name"></slot>
                      </div>
                      <div class="class-id">
                        <slot name="class-id"></slot>
                      </div>
                      <div class="score">
                        <slot name="score"></slot>
                      </div>
                    </div>
                  </div>
                  <div class="panel-content-botton">
                    <div class="botton-left">
                      <slot name="botton-left"></slot>
                    </div>
                    <div class="botton-right">
                      <slot name="botton-right"></slot>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="right-panel panel">
            <h5 class="tech-title">综合分析</h5>
            <slot name="panel-right"></slot>
          </div>
        </div>
        <!-- 底部面板布局 -->
        <div class="bottom-panel panel">
          <h5 class="tech-title">学生进步档案</h5>
          <slot name="panel-bottom"></slot>
        </div>
      </div>
      <!-- 右侧列布局 -->
      <div class="right-column">
        <div class="right-class">
          <div class="middle-content panel">
            <h5 class="tech-title">课前</h5>
            <slot name="middle-content1"></slot>
          </div>
          <div class="middle-content panel">
            <h5 class="tech-title">课中</h5>
            <slot name="middle-content2"></slot>
          </div>
          <div class="middle-content panel">
            <h5 class="tech-title">课后</h5>
            <slot name="middle-content3"></slot>
          </div>
          <div class="middle-content panel">
            <h5 class="tech-title">评语</h5>
            <slot name="middle-content4"></slot>
          </div>
        </div>
      </div>
    </div>
  </Framework>
</template>
<script>
export default {
  name: 'Specifices',
  methods: {
    switchStudent(direction) {
      if (!this.$store.state.options || !Array.isArray(this.$store.state.options)) {
        console.error('学生列表数据无效');
        return;
      }

      // 获取当前显示的学生列表
      const currentOptions = this.$store.state.options;
      const currentIndex = currentOptions.findIndex(
        student => student.studentId === this.$store.state.studentId
      );

      if (currentIndex === -1) {
        console.error('未找到当前学生');
        return;
      }

      let newIndex;
      if (direction === 'prev') {
        newIndex = currentIndex > 0 ? currentIndex - 1 : currentOptions.length - 1;
      } else {
        newIndex = currentIndex < currentOptions.length - 1 ? currentIndex + 1 : 0;
      }

      const newStudent = currentOptions[newIndex];

      // 更新 Vuex store
      this.$store.commit('updateStudentId', newStudent.studentId);

      // 更新父组件的 selectedValue
      this.$parent.selectedValue = newStudent;
      this.$parent.searchQuery = newStudent.studentName;

      // 强制更新下拉框的显示
      this.$nextTick(() => {
        const selectInput = this.$el.querySelector('.el-input__inner');
        if (selectInput) {
          selectInput.value = newStudent.studentName;
        }
      });
    }
  }
}
</script>
<style scoped>
/* 基础样式 */
.page-layout {
  width: 100%;
  height: 100%;
  display: flex;
  box-sizing: border-box;
  gap: 15px;
}

/* 主标题样式 */
.main-title {
  font-size: 24px;
  font-weight: bold;
  color: #00ffff;
  text-shadow: 0 0 10px rgba(0, 255, 255, 0.7);
  letter-spacing: 2px;
  margin-bottom: 5px;
  background: linear-gradient(90deg, transparent, rgba(0, 150, 255, 0.2), transparent);
  padding: 10px 0;
  position: relative;
  text-align: center;
}

.main-title::before,
.main-title::after {
  content: '';
  position: absolute;
  height: 1px;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 255, 0.8), transparent);
}

.main-title::before {
  top: 0;
}

.main-title::after {
  bottom: 0;
}

/* 面板通用样式 */
.panel {
  background: rgba(0, 20, 40, 0.7);
  border: 1px solid rgba(0, 255, 255, 0.3);
  border-radius: 4px;
  box-shadow: 0 0 15px rgba(0, 180, 255, 0.3);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.panel:hover {
  box-shadow: 0 0 25px rgba(0, 200, 255, 0.5);
  transform: translateY(-3px);
}

.tech-title {
  color: #00ffff;
  text-shadow: 0 0 8px rgba(0, 200, 255, 0.7);
  font-size: 16px;
  padding: 10px 15px;
  margin: 0;
  border-bottom: 1px solid rgba(0, 255, 255, 0.2);
  background: rgba(0, 30, 60, 0.4);
}

.tech-title::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 255, 255, 0.5), transparent);
}

.detail-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  row-gap: 15px;
}

/* 布局样式 */
.left-column {
  width: 75%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 15px;
  position: relative;
}

.right-column {
  width: 25%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 15px;
  position: relative;
}

.right-class {
  width: 100%;
  height: 115%;
  display: flex;
  flex-direction: column;
  gap: 15px;
  position: absolute;
  top: -15%;
}

.top-panel {
  display: flex;
  gap: 15px;
  height: 60%;
}

.bottom-panel {
  height: 40%;
}

.left-panel {
  width: 40%;
  height: 100%;
  position: relative;
}

.right-panel {
  width: 60%;
}

.middle-content {
  flex: 1;
}

.content {
  height: 109%;
  position: absolute;
  top: -25%;
}
/* 搜索 */
.search {
  color: aliceblue;
  width: 100%;
  height: 15%;
  display: flex;
  align-items: center;
}

.panel-content {
  width: 100%;
  height: 85%;
  margin-bottom: 0;
}

.panel-content {
  height: 100%;
  padding: 15px;
  position: relative;
  overflow: hidden;
}

.switch-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.switch-btn::before {
  content: '';
  width: 8px;
  height: 8px;
  border-top: 2px solid rgba(0, 160, 233, 0.8);
  border-right: 2px solid rgba(0, 160, 233, 0.8);
  transition: all 0.3s ease;
}

.switch-btn.prev {
  left: 0;
}

.switch-btn.next {
  right: 0;
}

.switch-btn.prev::before {
  transform: rotate(-135deg);
  margin-left: 4px;
}

.switch-btn.next::before {
  transform: rotate(45deg);
  margin-right: 4px;
}

.switch-btn:hover {
  background: rgba(0, 20, 40, 0.5);
  border-color: rgba(0, 160, 233, 0.6);
  box-shadow: 0 0 15px rgba(0, 160, 233, 0.3);
  border: 1px solid rgba(0, 160, 233, 0.3);
  border-radius: 50%;
}

.switch-btn:hover::before {
  border-color: rgba(0, 160, 233, 1);
  box-shadow: 0 0 10px rgba(0, 160, 233, 0.5);
}

.switch-btn:active {
  transform: translateY(-50%) scale(0.95);
}

/* 响应式调整 */
@media screen and (max-width: 1400px) {
  .switch-btn {
    width: 25px;
    height: 25px;
  }

  .switch-btn::before {
    width: 6px;
    height: 6px;
  }
}

@media screen and (max-width: 1200px) {
  .switch-btn {
    width: 20px;
    height: 20px;
  }

  .switch-btn::before {
    width: 5px;
    height: 5px;
  }
}

/* 学生详情 */
/* 上部 */
.panel-content-top {
  width: 100%;
  height: 60%;
  display: flex;
  gap: 15px;
}

/* 头像 */
.top-left {
  width: 40%;
  height: 100%;
}

/* 文字 */
.top-right {
  width: 60%;
  height: 100%;
}

/* 五角星 */
.right-top {
  width: 100%;
  height: 25%;
}

/* 姓名 */
.class-name {
  width: 100%;
  height: 25%;
}

/* 学号 */
.class-id {
  width: 100%;
  height: 25%;
  transition: all 0.3s ease;
}

/* 成绩 */
.score {
  width: 100%;
  height: 25%;
  transition: all 0.3s ease;
}

/* 下部 */
.panel-content-botton {
  width: 100%;
  height: 40%;
  display: flex;
  justify-content: space-around;
}

.botton-left {
  width: 40%;
  height: 65%;
  background: url('@/assets/center_num.png');
  background-size: 100% 100%;
}

.botton-right {
  width: 40%;
  height: 65%;
  background: url('@/assets/center_num.png');
  background-size: 100% 100%;
}

</style>